﻿using EMoney.IStock.Client.Models.QQ;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EMoney.IStock.Client.DataAccess.QQ
{
    /// <summary>
    /// 交易数据访问类
    /// </summary>
    public class TradeDal
    {
        /// <summary>
        /// 新增参赛信息
        /// </summary>
        /// <param name="qq"></param>
        /// <param name="tel"></param>
        /// <returns></returns>
        public int AddRegInfo(string qq,string tel)
        {
            string sql = "insert into QQ_RegInfo(QQ) values(@QQ)";

            SQLTools tools = new SQLTools();

            tools.AddSqlParameter("QQ", System.Data.SqlDbType.VarChar, qq);

            return SQLHelper.ExecuteNonQuery(ConnectionManager.Emfstock, System.Data.CommandType.Text, sql, tools.GetSqlParameters());
        }

        /// <summary>
        /// 获取报名信息
        /// </summary>
        /// <param name="qq"></param>
        /// <returns></returns>
        public RegInfo GetRegInfo(string qq)
        {
            string sql = "select * from QQ_RegInfo where qq=@qq";

            SQLTools tools = new SQLTools();

            tools.AddSqlParameter("qq", System.Data.SqlDbType.VarChar, qq);

            return SQLHelper.GetDataByColumns<RegInfo>(ConnectionManager.Emfstock, sql, tools.GetSqlParameters());
        }

        /// <summary>
        /// 更新报名信息
        /// </summary>
        /// <param name="reginfo"></param>
        /// <returns></returns>
        public int UpdateRegInfo(RegInfo reginfo)
        {
            string sql = "update QQ_RegInfo set Lottery=@Lottery,Abandon=@Abandon,Win=@Win,UpdateTime=getdate() where QQ=@QQ";

            SQLTools tools = new SQLTools();

            tools.AddSqlParameter("QQ", System.Data.SqlDbType.VarChar, reginfo.QQ);
            tools.AddSqlParameter("Lottery", System.Data.SqlDbType.Bit, reginfo.Lottery);
            tools.AddSqlParameter("Abandon", System.Data.SqlDbType.Bit, reginfo.Abandon);
            tools.AddSqlParameter("Win", System.Data.SqlDbType.Bit, reginfo.Win);

            return SQLHelper.ExecuteNonQuery(ConnectionManager.Emfstock, System.Data.CommandType.Text, sql, tools.GetSqlParameters());
        }
    }
}
